<?php

/**
 * LEAGUEMan
 * 
 * Copyright (C) 2007 Marko Bischof
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

?>

<table class="contentpane" style="border:1px solid #DDD">
	<tr>
		<td width="1%" class="sectiontableheader">#</td>
		<td width="22%" class="sectiontableheader">Anstoss</td>
		<td width="34%" class="sectiontableheader"><div align="right">Heim</div></td>
		<td class="sectiontableheader">&nbsp;</td>
		<td width="34%" class="sectiontableheader"><div align="left">Gast</div></td>
		<td width="8%" class="sectiontableheader" colspan="2">Ergebnis</td>
		<td width="1%" class="sectiontableheader"></td>
	</tr>
 
<?php

$goals	= 0;
$v		= 0;

foreach($this->matches as $match){
	
	if(is_numeric($match->match_result_0_1) && is_numeric($match->match_result_0_2)){
		$goals = $goals + $match->match_result_0_1 + $match->match_result_0_2;
		$v++;
	}
	
	$tm1		= sefRelToAbs("index.php?option=com_leagueman&func=teaminfo&tm=" . $match->teammap1);
	$tm2		= sefRelToAbs("index.php?option=com_leagueman&func=teaminfo&tm=" . $match->teammap2);
	
	$link		= sefRelToAbs(sprintf("index.php?option=com_leagueman&func=roundinfo&p=%s&r=%s", $match->match_project, $match->match_round)); 
	$matchlink	= sefRelToAbs(sprintf("index.php?option=com_leagueman&func=matchinfo&m=%s", $match->match_id));
?>
	<tr class="<?php $this->plugin("toggle", "sectiontableentry1", "sectiontableentry2");?>">
		<td><a href="<?php echo $link;?>"><?php echo $match->match_round;?></a></td>
		<td><?php $this->plugin("leagueman_get_match_datetime", $match, "%d.%m.%Y");?></td>
		<td><div align="right"><a href="<?php echo $tm1;?>"><?php echo $match->team1_name;?></a></div></td>
		<td><div align="center">-</div></td>
		<td><div align="left"><a href="<?php echo $tm2;?>"><?php echo $match->team2_name;?></a></div></td>
		<td><?php $this->plugin("leagueman_get_match_result", $match, 0);?></td>
		<td><?php $this->plugin("leagueman_get_match_result", $match, 1);?></td>
		<td><a href="<?php echo $matchlink;?>">(i)</a></td>
	</tr>
<?php

}
	
?>
	<tr>
		<td class="sectiontableheader" colspan="8">
			<div align="center"><?php printf("%s: %s (%1.2f %s)", _LM_TOTALGOALS, $goals, $this->splugin("leagueman_get_avg", $goals, $v), _LM_PERMATCH); ?></div>
		</td>
	</tr>

</table>